package life;

public class Life
{
	private World world;
	private int lisoAmmonut;
	private int foodAmmonut;
	private int lisoLifeSpan;
	private int foodLifeSpan;
	private int worldMaxAge;
	private double foodSpawnProbablility;
	
	public Life(World world, int lisoAmmonut, int foodAmmonut, int lisoLifeSpan, int foodLifeSpan, int worldMaxAge,double foodSpawnProbablility)
	{
		this.world=world;
		this.lisoAmmonut=lisoAmmonut;
		this.foodAmmonut=foodAmmonut;
		this.lisoLifeSpan=lisoLifeSpan;
		this.foodLifeSpan=foodLifeSpan;
		this.worldMaxAge=worldMaxAge;
		this.foodSpawnProbablility=foodSpawnProbablility;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args)
	{
		int lisoAmmonut=200; //Number of Liso at StartUp
		int foodAmmonut=800; //Number of food at Startup
		int lisoLifeSpan=1000; //LifeSpan Liso
		int foodLifeSpan=1000;  //LifeSpan Food
		int worldMaxAge=1000000000;	//max Age Possible For the World
		World world = new World(new Coordinate(200.0, 200.0));
		double foodSpawnProbablility=.99; //Food Generation Probability, each Cycle
		
		Life life = new Life(world,lisoAmmonut,foodAmmonut,lisoLifeSpan,foodLifeSpan, worldMaxAge,foodSpawnProbablility);
		life.process();

	}

	private void process()
	{
		world.createFood(foodAmmonut,foodLifeSpan); //set Food
		world.createLiso(lisoAmmonut,lisoLifeSpan); //Set Liso
		int cycle=0;
		do
		{
			cycle++;
			world.age(); //Age world
			world.moveLiso(); //move Liso in the world
			world.spawnFood(foodSpawnProbablility, foodLifeSpan); //Spawn New Food
			world.lisoEat(); //Liso eat if can
			world.spawnLiso();
			
			
			System.out.println(cycle+"\tfood:"+world.getFoodMap().size()+"\tLiso:"+world.getLisoMap().size());
		}
		while(world.age<worldMaxAge && world.asLisoAlive());
		
	}

}
